package sg.partying.lcb.android.ui

import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.alibaba.android.arouter.facade.annotation.Route
import com.blankj.utilcode.util.AppUtils
import com.blankj.utilcode.util.LanguageUtils
import com.salton123.base.DelegateActivity
import com.salton123.base.ViewBindingActivity
import com.salton123.base.feature.ImmersionFeature
import com.salton123.base.feature.PermissionFeature
import com.salton123.soulove.Constants
import com.salton123.utils.PreferencesUtils
import kt.singleClick
import kt.toast
import sg.partying.lcb.android.R
import sg.partying.lcb.android.Session
import sg.partying.lcb.android.databinding.ActivityHomeBinding
import sg.partying.lcb.android.databinding.FragmentLanguageChoiceBinding
import java.util.Locale


/**
 * Time:2022/1/29 11:40 上午
 * Author:
 * Description:
 */
class HomeActivity : DelegateActivity() {
    override fun getLayout(): Int = R.layout.fragment_language_choice

    override fun initVariable(savedInstanceState: Bundle?) {
        ImmersionFeature(this).onBind()
        PermissionFeature {
            if (!it) {
                toast("please grant all permissions")
                AppUtils.launchAppDetailsSettings()
            }
        }.onBind()
    }

    override fun initViewAndData() {
        findViewById<TextView>(R.id.tvChinese).singleClick {
            LanguageUtils.applyLanguage(Locale.SIMPLIFIED_CHINESE)
            openActivity(SelectBackgroundActivity::class.java, Bundle())
            finish()
        }
        findViewById<TextView>(R.id.tvEnglish).singleClick {
            LanguageUtils.applyLanguage(Locale.ENGLISH)
            openActivity(SelectBackgroundActivity::class.java, Bundle())
            finish()
        }
        findViewById<TextView>(R.id.tvSwitch).singleClick {
            if (PreferencesUtils.getBoolean("isFront")) {
                PreferencesUtils.putBoolean("isFront", false)
                toast(getString(com.salton123.translate.R.string.switch_to_back_camera))
            } else {
                PreferencesUtils.putBoolean("isFront", true)
                toast(getString(com.salton123.translate.R.string.switch_to_fron_camera))
            }
        }

    }

}
